package cn.stronglink.asset.message.mq.consumer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;

import cn.stronglink.asset.module.rfidState.service.RfidStateJdService;

@Component("jdReceiver")
public class JdReceiver implements MessageListener {

	@Autowired
	private RfidStateJdService rfidStateJdService;
	
	@Override
	public void onMessage(Message message) {
		if (!(message instanceof ActiveMQTextMessage)) {
			return;
		}
		TextMessage tm = (TextMessage) message;
		JDThreadExcute.executorService.execute(new JdThread(tm,rfidStateJdService));
	}
	
	public static void main(String[] args) {
		List<Integer> list =new ArrayList<>(Arrays.asList(3,4,5));
		 List<Integer> allList =new ArrayList<>(Arrays.asList(1,2,3,4,5,6,7,8,9));
		 
		for(int i=0;i<list.size();i++) {
			Iterator<Integer> it = allList.iterator();
			 while (it.hasNext()) {	
				 int cc =it.next();
				 System.out.println(list.get(i)+"%%%%%%%%%%%%");
				 if(cc==list.get(i)){
					 System.out.println(cc+"cc");
					 it.remove();
				 }		
			 }
		}
		
		System.out.println(JSON.toJSONString(allList)+"allList");
		System.out.println(JSON.toJSONString(list)+"list");
		
	}
	
	
	
}
